package com.suxin.webflux.workshop.domain;

import java.math.BigDecimal;
import java.math.MathContext;
import java.time.Instant;

/**
 * @Classname Quote
 * @Description [ TODO ]
 * @Author Tang
 * @Date 2021/1/4 13:14
 * @Created by ASUS
 */
public class Quote {

    private static final MathContext matchContext = new MathContext(2);

    private String ticker;

    private Instant instant;

    private BigDecimal price;

    public Quote() {

    }

    public Quote(String ticker, BigDecimal price) {
        this.ticker = ticker;
        this.price = price;
    }

    public Quote(String ticker, Double price) {
        this(ticker, new BigDecimal(price, matchContext));
    }

    public String getTicker() {
        return ticker;
    }

    public void setTicker(String ticker) {
        this.ticker = ticker;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public Instant getInstant() {
        return instant;
    }

    public void setInstant(Instant instant) {
        this.instant = instant;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Quote{" +
                "ticker='" + ticker + '\'' +
                ", instant=" + instant +
                ", price=" + price +
                '}';
    }
}